{% load client_lib_tags %}
{% load static from staticfiles %}

<link rel="stylesheet" type="text/css" href="{% static "geoexplorer/externals/GeoExt/resources/css/geoext-all.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "geoexplorer/externals/GeoExt/resources/css/gxtheme-gray.css" %}?v={{ VERSION }}">
<link rel="stylesheet" type="text/css" href="{% static "geoexplorer/theme/ux/colorpicker/color-picker.ux.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "geoexplorer/externals/PrintPreview/resources/css/printpreview.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "geoexplorer/externals/openlayers/theme/default/style.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "geoexplorer/externals/gxp/src/theme/all.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "geoexplorer/theme/app/geoexplorer.css" %}?v={{ VERSION }}" />
<!--[if IE]><link rel="stylesheet" type="text/css" href="{% static "geoexplorer/theme/app/ie.css" %}"/><![endif]-->

<link rel="stylesheet" type="text/css" href="{% static "geosk/css/site_base.css" %}?v={{ VERSION }}" />

<script src="{% static "geoexplorer/script/GeoExplorer.js" %}?v={{ VERSION }}" type="text/javascript"></script>
<script src="{% static "geosk/js/openlayers_sos.js" %}" type="text/javascript"></script>
<script src="{% static "geosk/js/gxp_extra.js" %}" type="text/javascript"></script>
<script src="{% static "geosk/js/geosk_sos.js" %}" type="text/javascript"></script>

<script type="text/javascript">
OpenLayers.ImgPath = "{% static "geoexplorer/externals/openlayers/theme/default/img" %}";
OpenLayers.Util.onImageLoadErrorColor = 1;
OpenLayers.Util.onImageLoadErrorColor = 'transparent';
OpenLayers.Util.onImageLoadError = function() {
    this.src = '{% static "geonode/img/light_gray.jpg';
};

OpenLayers.Request.DEFAULT_CONFIG.headers = {
  'X-CSRFToken': '{{ csrf_token|escapejs }}'
};

/**
*  Add GetFeedFeatureInfo tool to GeoExplorer.Viewer
*/
GeoExplorer.Viewer.prototype.loadConfig = function(config) {

  try {
      config.tools.push( {
        ptype: "gxp_legend",
        checked: true
      });
  } catch(err) {
      console.log(err);
  }

  // remove the 3D Viewer if no Google API Key is availbale
  var google_api_key = '{% google_api_key %}';
  if(google_api_key.length == 0 || 'None' == google_api_key) {
    config.viewerTools.splice(10,1);
  }

  config.viewerTools.push( {
    ptype: "gxp_getfeedfeatureinfo",
    checked: true
  });

  config.viewerTools.push({
      ptype: "gxp_playback",
      checked: true,
      outputTarget: "paneltbar"
  });

  // Do not include the layer styler on the map-detail view.
  {% if not map %}
    {% if user.is_authenticated %}
      config.viewerTools.splice(5, 0, {
        id: "styler",
        ptype: "gxp_styler",
        checked: true
      });
    {% endif %}
  {% endif %}

  GeoExplorer.Viewer.superclass.loadConfig.call(this, config);
};

var _register_disableObliqueView_interval;
//
function disableObliqueView(){
    if (typeof app == "undefined") {
        return;
    }
    if (typeof app.mapPanel == "undefined") {
        return;
    }
    if (typeof app.mapPanel.layers == "undefined") {
        return;
    }
    var layers = app.mapPanel.map.layers;
    Ext.each(layers, function(layer){
        if(layer.typeName == 'SATELLITE'){
            if (typeof layer.mapObject == "undefined") {
                return;
            }

            layer.mapObject.setTilt(0);
            clearInterval(_register_disableObliqueView_interval);
        }
    });
}
_register_disableObliqueView_interval = setInterval(disableObliqueView, 1000);

GeoExplorer.Composer.prototype.loadConfig = function(config) {
  GeoExplorer.Composer.superclass.loadConfig.call(this, config);
};

</script>

<!-- geosk -->
<style>
/* OpenSeaMap needs to remove pink tiles */
.olImageLoadError {
    /* when OL encounters a 404, don't display the pink image */
    display: none !important;
}
</style>
<script src="{% static "geosk/js/OpenSeaMapSource.js" %}" type="text/javascript"></script>
